/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.kiakaku.downloadpage;


import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/*
 *   File URLUtility is created by kiakaku on Feb 16, 2012 10:55:39 AM
 * If you want modify this file please insert information in here 
 * - Last modify in Feb 16, 2012, 10:55:39 AM by kiakaku
 *                  
 *
 * @author kiakaku
 */
public class URLUtility { public static void main(String[] arguments) throws Exception{
    String page = loadPage("M:/abc.html");
    Pattern pattern = Pattern.compile("<a.+href=\"(.+?)\"");
    Matcher matcher = pattern.matcher(page);
    while (matcher.find()) {
      System.out.println(matcher.group(1));
    }
  }

  static String loadPage(String name) throws Exception {
    StringBuffer output = new StringBuffer();
    FileReader file = new FileReader(name);
    BufferedReader buff = new BufferedReader(file);
    boolean eof = false;
    while (!eof) {
      String line = buff.readLine();
      if (line == null)
        eof = true;
      else
        output.append(line + "\n");
    }
    buff.close();
    return output.toString();
  }
}
